#include	<sstream>
#include	"SubWinLines.hpp"

SubWinLines::SubWinLines(unsigned int heightWinCode, unsigned int widthWinCode, WINDOW *winCode, unsigned int widthSubWinWarning)
{
  (void)widthWinCode;
  this->_height = heightWinCode - 2;
  this->_width = 5;
  this->_win = derwin(winCode, this->_height, this->_width, 1, 1 + widthSubWinWarning);
  box(this->_win, 0, 0);
  wrefresh(this->_win);
}

SubWinLines::~SubWinLines()
{
  
}

void	SubWinLines::checkEvent(int event)
{
  
}

void	SubWinLines::update(bool focus)
{
  box(this->_win, 0, 0);
}

void	SubWinLines::updateLines(unsigned int startDisplay, unsigned int len)
{
  unsigned int			jump = 0;
  std::ostringstream	oss;
  std::string		tmp;

  while (jump < len)
    {
      oss.str("");
      oss << startDisplay + 1;
      tmp = oss.str();
      while (tmp.length() < this->_width - 2)
	tmp += " ";
      mvwprintw(this->_win, jump + 1, 1, "%s", tmp.c_str());
      startDisplay++;
      jump++;
    }
  wrefresh(this->_win);
}
